package weather;

import java.util.Observable;
import java.util.Observer;

public class CurrentConditionsDisplay implements Observer, DisplayElement {

    private float temperature;
    private float humidity;
    private float pressure;
    Observable observable;

    public CurrentConditionsDisplay(Observable observable) {
        this.observable = observable;
        observable.addObserver(this);
    }

    public void update(Observable obs, Object arg) {
        if (obs instanceof WeatherData) {
            WeatherData weather = (WeatherData) obs;
            this.temperature = (weather.getTemperature());
            this.humidity = (weather.getHumidity());
            this.pressure = (weather.getPressure());
            display();
        }
    }

    public void display() {
        System.out.println("** Current weather conditions: " + temperature
                + "C degrees and " + humidity + "% humidity" + " and " + pressure + " pressure");
    }
}